package jzqb.controller;

import haha.life.common.SysTool;
import haha.life.normal.FileUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * Description: 定时任务-->删除上传的临时文件
 *
 * @author BaiGe
 * @date: 2021/8/24 10:07
 * @Version 1.0
 */
@Component
public class ScheduleController {
    //封面储存临时路径
    @Value("${filePath.coverTemPResource}")
    private String coverTemPResource;
    //文件件储存临时路径
    @Value("${filePath.fileTemPResource}")
    private String fileTemPResource;

   //   @Scheduled(cron = "0 0 4 1/7 * ?")//表示每隔七天凌晨四点开始执行
    @Scheduled(cron = "0 0 4 ? * 7")//每周星期日凌晨4点实行一次
    public void delTempFile() {
        if (coverTemPResource.contains("\\temp\\")) {
            boolean b1 = FileUtil.deleteFolder(coverTemPResource);
            System.out.println(b1);
        }
        if (fileTemPResource.contains("\\temp\\")) {
            boolean b2 = FileUtil.deleteFolder(fileTemPResource);
            System.out.println(b2);
        }
        System.out.println("删除了 "+ SysTool.getCurrentTime(SysTool.dateFormat_milli));
    }
}
